package de.tu_darmstadt.gdi.battleship;
/**
 * 
 * @author Mischa Lundberg
 *
 */
public class CheckLevelStatus {
	


	Ship ship;
	/**
	 * The Left Player Won
	 * 
	 * @param map
	 * @return
	 */
	public boolean wonLeft (char[][]map){//(Ship[][] map){
		int shipCounter = 0;
			for(int i=0; i<11; i++){
				for(int p=0; p<10; p++){
					//if(ship.equals(map[i][p])){
					if(map[i][p] == '-' || map[i][p] == 't' || map[i][p] == 'b' || map[i][p] == 'h' || map[i][p] == 'v' || map[i][p] == 'r' || map[i][p] == 'l'){
						shipCounter++;}
					else shipCounter+=0;
				}
			}
			if(shipCounter==0)return true;
			else return false;
		}
		

	/**
	 * The Right Player Won 
	 * 
	 * @param map
	 * @return
	 */
	private boolean wonRight(char[][]map){//(Ship[][] map){
		int shipCounter = 0;
		for(int i=12; i<21; i++){
			for(int p=0; p<10; p++){
				//if(ship.equals(map[i][p])){
				if(map[i][p] == 't' || map[i][p] == 'b' || map[i][p] == 'h' || map[i][p] == 'v' || map[i][p] == 'r' || map[i][p] == 'l'){
					shipCounter++;}
				else shipCounter+=0;
			}
		}
		if(shipCounter==0)return true;
		else return false;
	}
	
	

	/**
	 * Which Player Won the Match
	 * 
	 * @param map
	 * @return
	 */
	public String whoWon (char[][]map){//(Ship[][] map){
		
		if(wonRight (map))	return "Right Player Won the Game";
		else if (wonLeft (map)) return "Left Player Won the Game";
		else return "Failure, No Winner!";
	}
	
	/**
	 * Level End arrived?
	 * 
	 * @param map
	 * @return
	 */
	public boolean levelComplete (char[][]map){//(Ship[][] map){
		if (wonRight (map) || wonLeft (map))
			return true;
		else return false;
	}
}
